package com.heima.common.exception;

import com.heima.common.dto.ResponseResult;
import com.heima.common.enums.AppHttpCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zsk
 * @create 2022-04-10-16:09
 */
@RestControllerAdvice//针对所有的RestController添加了AOP
@Slf4j//日志功能
public class BaseExceptionHandler {

    //指定捕获的异常
    @ExceptionHandler(value = Exception.class)
    public ResponseResult handlerException(Exception e){
        //打印日志信息
        log.error(e.getMessage());
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }



}
